<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		// 给定两个大小分别为 m 和 n 的正序（从小到大）数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。
		
		
		onLoad() {
			let nums1 = [1,3]
			let nums2 = [2,4,5,6,7]
			let res = this.findMedianSortedArrays(nums1,nums2)
			console.log(res)
		},
		methods: {
			findMedianSortedArrays(nums1,nums2) {
				// console.log(nums1,nums2)
				let arr = nums1.concat(nums2).sort(function(a,b){
					return  a-b;
				})
				// console.log(arr)
				let num = arr.length
				let res = 0
				if(num % 2 == 0){
					// console.log(arr[num/2],arr[(num/2)-1])
					return (arr[num/2] + arr[(num/2)-1]) / 2
					
				}else{
					return arr[ Math.floor(num/2)]
				}
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
